import {request} from "../../utils/request"

const app = getApp()
Page({
  data: {
    text1: '',
    text2: '',
    text3: '',
    text4: ''
  },
  onLoad() {
    wx.getLocation({
      type: 'gcj02',
      success (res) {
        const latitude = res.latitude
        const longitude = res.longitude
        const speed = res.speed
        const accuracy = res.accuracy
        console.log(res)
      }
    })
  },
  handleText1(e) {
    this.setData({
      text1: e.detail.value
    })
  },
  handleText2(e) {
    this.setData({
      text2: e.detail.value
    })
  },
  handleText3(e) {
    this.setData({
      text3: e.detail.value
    })
  },
  handleText4(e) {
    this.setData({
      text4: e.detail.value
    })
  },
  handleAddLine() {
    request({
      url: '/admin/insertCoordinate',
      method: 'POST',
      data: {
        voltageLevel: this.data.text1,
        stationName: this.data.text2,
        lineName: this.data.text3,
        deviceName: this.data.text4
      },
      header: {
        'Authorization': app.globalData.token
      }
    })
    .then(res => {
      console.log(res)
    })
  }
  
})